﻿Imports QLPhuTungOto.Data
Imports DevExpress.LookAndFeel

Public Class frmDangNhap
    Dim ht As New HamHoTro
    Private Sub btnDangNhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangNhap.Click
        Dim db As New QLPhuTungOtoDataContext
        Dim ngDung As New NguoiDung

        Dim TenDangNhap As String = ""
        Dim mk As String = ""
        TenDangNhap = txtTenDangNhap.Text
        mk = HamHoTro.MaHoaMD5x2(txtMatKhau.Text)
        Try
            ngDung = (From c In db.NguoiDung Where c.TenDangNhap = TenDangNhap AndAlso c.MatKhau = mk Select c).First()
            DialogResult = Windows.Forms.DialogResult.OK
           

        Catch ex As Exception
            MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng")
            txtTenDangNhap.Text = ""
            txtMatKhau.Text = ""
            txtTenDangNhap.Focus()
        End Try

        
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Application.Exit()
    End Sub

    Private Sub frmDangNhap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtTenDangNhap.Text = "admin"
    End Sub
End Class